<?php
	class PostModel extends Model{
		function send($send){
			if($_POST['title']){
				$back['z']='error';
				$back['re']="请填写完整！";
			}
			$add['uid']=$_SESSION['uid'];
			$add['time']=time();
			$add['ip']=$_SERVER['REMOTE_ADDR'];
			$add['title']=$send['title'];
			$add['miao']=$send['miao'];
			$add['text']=$send['text'];
			$add['tag']=$send['tag'];
			$add['pd']=$send['pd'];
			if($send['image']){
				$add['image']=$send['image'];
			}
			$re=$this->add($add);
			$back['z']='success';
			$back['re']=$re;
			return $re;
		}
		function mypost($pid){
			$pid=(int)$pid;
			$post=$this->find($pid);
			if($post['uid']==$_SESSION['uid']){
				$back['z']='success';
				$back['re']=$post;
			}else{
				$back['z']='error';
				$back['re']="权限错误！";
			}
			return $back;
		}
		function edit($send){
			$add['retime']=time();
			$add['reip']=$_SERVER['REMOTE_ADDR'];
			$add['title']=$send['title'];
			$add['miao']=$send['miao'];
			if($send['image']){
				$add['image']=$send['image'];
			}
			$add['text']=$send['text'];
			$add['tag']=$send['tag'];
			$add['pd']=$send['pd'];
			$add['pid']=$send['pid'];

			$re=$this->save($add);
			if($re){
				$back['z']='success';
				$back['re']=$add['pid'];
				return $back;
			}

		}
		function pid($pid){
			$pid=(int)$pid;
			$re=$this->find($pid);
			if($re){
				return $re;
			}
		}
	}